package com.erp.erp_servers.Company.imp;

import com.erp.erp_dao.Company.ICompanyDAO;
import com.erp.erp_entitys.Company.CompanyEntity;
import com.erp.erp_entitys.Company.CompanyEntityExample;
import com.erp.erp_servers.Company.ICompanyService;
import com.erp.vo.SelectVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName ImpCompanyService
 * @Description TODO
 * @Author songjizhen
 * @Date 2020-06-29 20:05
 * @Version 1.0
 */
@Service
public class ImpCompanyService implements ICompanyService {
    @Autowired
    ICompanyDAO companyDAO;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return companyDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(CompanyEntity record) {
        int num = companyDAO.insertSelective(record);
        return num;
    }

    /**
     * 获取公司主信息
     *
     * @param pid
     */
    @Override
    public List<CompanyEntity> selectByExample(String pid) {
        CompanyEntityExample example=new CompanyEntityExample();
        CompanyEntityExample.Criteria criteria = example.createCriteria();
        criteria.andPidEqualTo(pid);
        List<CompanyEntity> companyEntities = companyDAO.selectByExample(example);
        return companyEntities;
    }

    @Override
    public CompanyEntity selectByPrimaryKey(Integer id) {
        return companyDAO.selectByPrimaryKey(id);
    }


    @Override
    public int update(CompanyEntity record) {
        CompanyEntityExample example=new CompanyEntityExample();
        CompanyEntityExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(record.getId());
        return companyDAO.updateByExampleSelective(record,example);
    }

    @Override
    public List<SelectVo> getAllList() {
        return companyDAO.getAllList();
    }


}
